package com.daxue.configtest.controller;

import com.daxue.configtest.repository.remoteconfig.ConfigEntity;
import com.daxue.configtest.repository.remoteconfig.ConfigRepository;
import com.daxue.configtest.exception.impl.ConflictException;
import com.daxue.configtest.exception.impl.NotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author daxue0929
 * @date 2023/3/24
 */

@RestController
public class TestController {

    final ConfigRepository configRepository;

    @Autowired
    public TestController(ConfigRepository configRepository) {
        this.configRepository = configRepository;
    }

    @GetMapping("/config/{id}")
    public Object getConfig(@PathVariable String id) throws ConflictException, NotFoundException {
        ConfigEntity configEntity = configRepository.read(id);
        return configEntity;
    }

}
